home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d6 / glazer.arc / TERMDEPO.BAS < prev   
BASIC Source File  |  1988-10-07  |  3KB  |  67 lines

  1. 100 'Term Deposit ("TERMDEPOSIT")
  2. 110 CLS
  3. 120 COLOR 0,15 : PRINT "Term Deposit" : COLOR 15,0
  4. 130 DEFDBL A-Z
  5. 140 DEFINT M-N
  6. 150 'Define rounding function
  7. 160 DEF FNR (V) = SGN (V) * INT (ABS (V) * 100 + .5) / 100
  8. 170 MONEYFMT$ = "$$##,###,###.##"
  9. 180 '     Let user select result
  10. 190 PRINT
  11. 200 PRINT "Select desired result:"
  12. 210 PRINT
  13. 220 PRINT "1 - Initial deposit"
  14. 230 PRINT "2 - Required interest rate"
  15. 240 PRINT "3 - Final balance"
  16. 250 PRINT "4 - Required term"
  17. 260 PRINT
  18. 270 INPUT "Result number: ", RESULT
  19. 280 IF (RESULT < 1) OR (RESULT > 4) THEN PRINT "Select 1-4 only" : GOTO 200
  20. 290 PRINT
  21. 300 '     Let user enter data
  22. 310 PRINT "Do not enter dollar signs or commas"
  23. 320 PRINT
  24. 330 IF RESULT <> 1 THEN INPUT "Initial deposit: ", PV
  25. 340 IF RESULT <> 2 THEN INPUT "Annual interest rate (in percent): ", AR
  26. 350 IF RESULT <> 3 THEN INPUT "Savings goal: ", FV
  27. 360 IF RESULT <> 4 THEN INPUT "Term (in months): ", NMONTHS
  28. 370 INPUT "Annual inflation rate (in percent): ", INFLATION
  29. 380 INPUT "Marginal tax rate (in percent): ", TAXRATE
  30. 390 '     Initialize values
  31. 400 PR = (1 + AR / 100) ^ (1/12) - 1
  32. 410 'After tax interest rate
  33. 420 PR = PR * (1 - TAXRATE / 100)
  34. 430 'Monthly inflation rate
  35. 440 INFLATION = (1 + INFLATION / 100) ^ (1/12) - 1
  36. 450 'Effective interest rate
  37. 460 REFFECTIVE  = (1 + PR) / (1 + INFLATION) - 1
  38. 470 PRINT
  39. 480 ON RESULT GOTO 500, 540, 670, 710
  40. 490 '     Result 1: Initial deposit
  41. 500 PV = FV * (1 + REFFECTIVE) ^ -NMONTHS
  42. 510 PRINT "Initial deposit: "; USING MONEYFMT$; PV
  43. 520 END
  44. 530 '     Result 2: Required interest rate
  45. 540 INFV = FV * (1 + INFLATION) ^ NMONTHS
  46. 550 'Monthly interest rate
  47. 560 PR = (INFV / PV) ^ (1 / NMONTHS) - 1
  48. 570 'Annual interest rate
  49. 580 AR = ( (1 + PR) ^ 12 - 1) * 100
  50. 590 'Adjust for taxes
  51. 600 RTAXABLE = PR / (1 - TAXRATE / 100)
  52. 610 RTAXABLE = ( (1 + RTAXABLE) ^ 12 - 1) * 100
  53. 620 'Print results
  54. 630 PRINT "Taxable interest rate: "; FNR(RTAXABLE); "%"
  55. 640 PRINT "Tax-free interest rate:"; FNR(AR); "%"
  56. 650 END
  57. 660 '     Result 3: Final balance
  58. 670 FV = PV * (1 + REFFECTIVE) ^ NMONTHS
  59. 680 PRINT "Final balance:"; USING MONEYFMT$; FV
  60. 690 END
  61. 700 '     Result 4: Required term
  62. 710 IF FV <> PV  THEN NMONTHS = LOG (FV / PV) / LOG (1 + REFFECTIVE)                             ELSE NMONTHS = 0
  63. 720 IF NMONTHS < 0  THEN PRINT "No solution" : END
  64. 730 IF (NMONTHS - INT (NMONTHS) ) < .001  THEN NMONTHS = INT (NMONTHS)                 ELSE NMONTHS = INT(NMONTHS) + 1
  65. 740 PRINT "Required number of months: "; NMONTHS
  66. 750 END
  67.